<template>
    <!-- model: 表单数据对象 -->
    <el-form :model="form" label-width="auto" style="max-width: 600px">

        <!-- 输入框 -->
        <el-form-item label="活动名称">
            <el-input v-model="form.name" />
        </el-form-item>

        <!-- 下拉框 -->
        <el-form-item label="活动区域">
            <el-select v-model="form.region" placeholder="请选择您的区域">
                <el-option label="Zone one" value="shanghai" />
                <el-option label="Zone two" value="beijing" />
            </el-select>
        </el-form-item>

        <!-- 选择日期时间 -->
        <el-form-item label="活动时间">
            <!-- span: 行内占比 -->
            <el-col :span="11">
                <el-date-picker v-model="form.date1" type="date" placeholder="选择一个日期" style="width: 100%" />
            </el-col>
            <el-col :span="2" class="text-center">
                <span class="text-gray-500">-</span>
            </el-col>
            <el-col :span="11">
                <el-time-picker v-model="form.date2" placeholder="选择一个时间" style="width: 100%" />
            </el-col>
        </el-form-item>

        <!-- 是否即时交付 -->
        <el-form-item label="即时交付">
            <el-switch v-model="form.delivery" />
        </el-form-item>

        <!-- 活动类型 -->
        <el-form-item label="活动类型">
            <el-checkbox-group v-model="form.type">
                <el-checkbox value="Online activities" name="type">
                    在线活动
                </el-checkbox>
                <el-checkbox value="Promotion activities" name="type">
                    促销活动
                </el-checkbox>
                <el-checkbox value="Offline activities" name="type">
                    离线活动
                </el-checkbox>
                <el-checkbox value="Simple brand exposure" name="type">
                    简单活动曝光
                </el-checkbox>
            </el-checkbox-group>
        </el-form-item>

        <!-- 资源 -->
        <el-form-item label="资源">
            <el-radio-group v-model="form.resource">
                <el-radio value="Sponsor">赞助商</el-radio>
                <el-radio value="Venue">场地</el-radio>
            </el-radio-group>
        </el-form-item>

        <!-- 活动表单 -->
        <el-form-item label="活动表单">
            <el-input v-model="form.desc" type="textarea" />
        </el-form-item>

        <!-- 创建取消活动 -->
        <el-form-item>
            <el-button type="primary" @click="onSubmit">Create</el-button>
            <el-button>Cancel</el-button>
        </el-form-item>
    </el-form>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

// do not use same name with ref
const form = ref({
    name: '',
    region: '',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: '',
})

const onSubmit = () => {
    console.log('submit!')
}
</script>

<style lang="scss" scoped></style>